model = Sketchup.active_model
selection = Sketchup.active_model.selection
file=model.path
路径 = File.dirname(file).freeze
文件名 = File.basename(file, '.*')
today = Time.new;
时间后缀= today.strftime("%Y%m%d_%H%M%S");
另存文件名=文件名

另存文件名=另存文件名+'_导出'+时间后缀
总另存全名=路径+'/'+另存文件名+'.skp'
status = model.save(总另存全名)

model = Sketchup.active_model
file=model.path
路径 = File.dirname(file).freeze
文件名 = File.basename(file, '.*')
entities = model.entities
for e in entities do
  if !( e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group ))
    e.erase!
  end
end
model.save

entities = model.entities
总数量=entities.count
puts "总数量"
puts 总数量
拟导出组名s=[]
for 拟导出组 in entities do
  组件名=拟导出组.name
  拟导出组名s.push 组件名
end

for i in 0...总数量
  组件名=拟导出组名s[i]
  另存全名=路径+'/'+组件名+'.skp'
  status = model.save(另存全名)
  model = Sketchup.active_model
  entities = model.entities
  # puts "总数量2"
  # puts entities.count
  拟删除组件s=[]
  for k in 0...总数量
    if k!=i
      puts "k"
      puts k
      拟删除组件=entities[k]
      puts "拟删除组件.name"
      puts 拟删除组件.name
      拟删除组件s.push 拟删除组件
      # 拟删除组件.erase!
    end
  end
  for 拟删除组件 in 拟删除组件s do
    拟删除组件.erase!
  end
  model.save

  if i < 总数量-1
    result = Sketchup.open_file(总另存全名)
    model = Sketchup.active_model
  end
end
